package com.shengcheng.config;

import com.shengcheng.constant.RedisConstant;
import lombok.AllArgsConstructor;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BloomFilterConfig {

    @Autowired
    private RedissonClient redissonClient;

    public RBloomFilter albumBloomFilter(){
        //指定布隆过滤器的名称
        RBloomFilter<Long> bloomFilter = redissonClient.getBloomFilter(RedisConstant.ALBUM_BLOOM_FILTER);
        //初始化布隆过滤器的大小和容错率
        bloomFilter.tryInit(10000,0.001);
        return bloomFilter;
    }
}
